import express from 'express';
import bodyParser from 'body-parser';
import contentRoutes from './routes/contentRoutes.js';
import scheduleRoutes from './routes/scheduleRoutes.js';
import cors from 'cors';

const app = express();

// 中间件
app.use(cors());
app.use(bodyParser.json());

// 路由
app.use('/api', contentRoutes);
app.use('/api', scheduleRoutes);

// 健康检查
app.get('/health', (req, res) => {
  res.status(200).json({ status: 'ok' });
});

// 启动服务器
const PORT = process.env.PORT || 3001;
app.listen(PORT, () => {
  console.log(`服务器运行在端口 ${PORT}`);
});